<?php

namespace App\Http\Repositories\EdgeManage;

use App\Http\Repositories\Repository;
use App\Models\Problem;

/**
 * 问题反馈相关
 */
class ProblemRepo extends Repository
{
    const MODEL =Problem::class;

    public function search(array $params)
    {

        $conditions = [];

        if (!empty($params['title'])) {
            array_push($conditions, ['title', 'where', ['like', '%' . $params['title'] . '%']]);
        }

        if (!empty($params['detail'])) {
            array_push($conditions, ['detail', 'where', ['like', '%' . $params['detail'] . '%']]);
        }

        if (!empty($params['begin_time'])) {
            array_push($conditions, ['created_at', 'where', ['>=', $params['begin_time']]]);
        }

        if (!empty($params['end_time'])) {
            array_push($conditions, ['created_at', ' where', ['<=', $params['end_time']]]);
        }

        return $this->formatSearch($conditions);
    }
}
